#ifndef CHEMNITZ_CTR_H
#define CHEMNITZ_CTR_H

#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "chemnitz.h"

typedef /*@abstract@*/ struct 
{
	uint8_t key [16];
	uint64_t iv;
	uint64_t ctr;
	uint8_t buffer [BYTES_PER_BLOCK];
	uint8_t index;
} *CHEMNITZ_STREAM;

/*@null@*/ CHEMNITZ_STREAM chemnitz_stream_open (/*@unique@*/ const uint8_t const *key, const uint64_t iv);
/*@falsewhennull@*/ bool chemnitz_stream_is_open (const CHEMNITZ_STREAM stream) /*@*/;
size_t chemnitz_stream_read (/*@notnull@*/ CHEMNITZ_STREAM stream, /*@out@*/ uint8_t *const buffer, size_t count) 
	/*@modifies stream@*/ 
	/*@modifies *buffer@*/;
void chemnitz_stream_close (/*@only@*/ /*@out@*/ /*@null@*/ CHEMNITZ_STREAM stream);

#endif

